import {getCate,getbanner,gethortgoods} from '../../request/api.js'

const state = {
    list:[],
    // 轮播图
    ban:[],
    // 中间
    goods:[]
}
const mutations = {
    changelist(state,arr){
        state.list = arr
    },
    changebanner(state,bani){
        state.ban = bani
    },
    changegoods(state,goodsi){
        state.goods = goodsi
    }
}
const actions = {
    asynclist(context){
        getCate().then(res=>{
            context.commit("changelist",res.data.list)
        })
    },
    asyncban(context){
        getbanner().then(res=>{
            context.commit("changebanner",res.data.list)
        })
    },
    asyncgoods(context){
        gethortgoods().then(res=>{
            context.commit("changegoods",res.data.list)
        })
    }
}
const getters = {
    list(state){
        return state.list
    },
    ban(state){
        return state.ban
    },
    goods(state){
        return state.goods
    }
}


export default{
    state,
    mutations,
    getters,
    actions,
    namespaced: true
}
